using System;
using System.Linq;
using System.Reflection;

namespace Cz
{
    public static class CzTypeTool
    {
        public static Type GetServiceType(this ICzBase service)
        {
            return service.GetType().GetServiceType();
        }
        
        public static Type GetServiceType(this Type type)
        {
            return type.GetInterfaces().First(t => t.GetCustomAttribute<CzService>() != null);
        }
    }
}